<template>
	<view>
		<u-sticky bgColor="#6492FF" offsetTop=0 customNavHeight=0>
			<navbox title="直属下级"></navbox>
			<view class="list">
				<u-search placeholder="请输入下级名称" @search="getlist" @custom='getlist' :actionStyle='{color:"#fff"}'
				 v-model="keyword"></u-search>
			</view>
		</u-sticky>

		<view class="list" v-if="list.length>0">
			<view class="list__item" v-for="(item,index) in list" :key="index">
				<view class="u-flex u-flex-y-center">
					<image :src="item.headUrl" class="list__item__tx" mode="aspectFill"></image>
					<view class="list__item__center">
						<view class="list__item__name">
							{{item.name}}
							<view class="list__item__lv u-flex u-flex-y-center" v-if="item.accountType==0">
								普通帐号
							</view>
							<view class="list__item__lv u-flex u-flex-y-center lv1" v-if="item.accountType==2">
								<image src="/static/img/my/tz.png" style="height: 28rpx;margin-right: 12rpx;"
									mode="heightFix"></image>团长账户
							</view>
							<view class="list__item__lv u-flex u-flex-y-center lv2" v-if="item.accountType==1">
								<image src="/static/img/my/jp.png" style="height: 28rpx;margin-right: 12rpx;"
									mode="heightFix"></image>金牌账户
							</view>
							<view class="list__item__lv u-flex u-flex-y-center lv2" v-if="item.accountType==3||item.isPartener==1">
								<image src="/static/img/my/jp.png" style="height: 28rpx;margin-right: 12rpx;"
									mode="heightFix"></image>合伙人
							</view>
						</view>
						<view class="list__item__phone">
							{{item.tel}}
						</view>
					</view>
				</view>
				<view class="list__item__btn" @click="navto('/pages/team/commission?childId='+item.id)"
					v-if="item.accountType==1||item.accountType==0">
					单独设置 佣金比例
				</view>
			</view>
		</view>

		<view class="" v-else style="margin-top: 200rpx;">
			<u-empty icon="/static/img/index/empty.png" mode="data" text="暂时没有数据"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		groupchild
	} from '@/api/team.js'
	export default {
		data() {
			return {
				keyword: '',
				list: []
			};
		},
		methods: {
			getlist() {
				groupchild({
					name: this.keyword
				}).then(res => {
					uni.stopPullDownRefresh()
					if (res.data.code == 200) {
						this.list = res.data.data
					}
				})
			},
		},
		onLoad() {
			this.getlist()
		},
		onPullDownRefresh() {
			this.getlist()
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f6f6f6;
	}

	.list {
		padding: 25rpx 16rpx;

		&__item {
			margin-bottom: 25rpx;
			background: #FFFFFF;
			border-radius: 14rpx;
			padding: 24rpx 38rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			&__tx {
				width: 118rpx;
				height: 118rpx;
				border-radius: 10rpx;
				margin-right: 32rpx;
			}

			&__center {
				height: 118rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;

			}
			&__lv {
				padding: 0 20rpx;
				line-height: 50rpx;
				border-radius: 25rpx;
				font-family: Source Han Sans SC;
				font-weight: 400;
				font-size: 25rpx;
				color: #6492FF;
				margin-left: 10rpx;
			}
			&__name {
				font-family: Source Han Sans SC;
				font-weight: bold;
				font-size: 26rpx;
				color: #3E3D3D;
				line-height: 26rpx;
				margin-bottom: 26rpx;
				display: flex;
				align-items: center;
			}

			&__phone {
				font-family: Source Han Sans SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #707070;
				line-height: 26rpx;
			}

			&__btn {
				width: 104rpx;
				height: 97rpx;
				background: #6492FF;
				border-radius: 7rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				padding: 0 18rpx;
				font-family: Source Han Sans SC;
				font-weight: 400;
				font-size: 26rpx;
				color: #FFFFFF;
				line-height: 35rpx;
			}
		}
	}

	.lv1 {
		color: #2C2C2C;
		border-color: #2C2C2C;
	}

	.lv2 {
		color: #F6BC0A;
		border-color: #F6BC0A;
	}
</style>